#!/usr/bin/env python

import sys
import gettext
from mxit import handles as h
import gui.constants as ic
import const as c

gettext.install('blendIT','locale');


class Presence:
   # const - pymxit Constant
   # text - Human-readable description/name
   # image - Default Image
   # jimg - Image when buddy has just logged in/out
   # timage - Tray presence image
   def __init__(self,const=None,text=None,image=None,jimg=None,timage=None):
      self.const = const;
      self.text = text;
      self.image = image;
      self.jimg = jimg;
      self.timage = timage;
   
   def is_online(self):
      if self.const in (h.Presence.OFFLINE,h.Presence.PENDING):
         return False;
      else:
         return True;

   @property
   def int(self):
      return int(self.const.id);

   @property
   def id(self):
      return self.int;

class Mood:
   def __init__(self,const=None,text=None,image=None):
      self.const = const;
      self.text = text;
      self.image = image;

   @property
   def int(self):
      return int(self.const.id);

   @property
   def id(self):
      return self.int;

   # We always want "None" to be at the top of the list
   # so we make it that.   
   @property
   def sort(self):
      if self.const == h.Mood.NONE:
         return 'a';
      else:
         return self.text;

class Emoticon:
   def __init__(self,pattern=None,image=None,text=None):
      self.pattern = pattern;
      self.text = text;
      self.image = image;

class Type:
   def __init__(self,const=None,text=None,cint=0,image=None):
      self.const = const;
      self.text = text;
      self.int = cint;
      self.image = image;
      self.id = cint;

class C:
   def __init__(self):
      pass;

   # TYPES
   types = {
      h.BuddyType.MXIT: Type(h.BuddyType.MXIT,_("MXit Contact"),c.BUDDY,ic.IMG_Buddy),
      h.BuddyType.JABBER: Type(h.BuddyType.JABBER,_("Jabber Contact"),c.BUDDY,ic.IMG_Buddy),
      h.BuddyType.SERVICE: Type(h.BuddyType.SERVICE,_("MXit Service"),c.SERVICE,ic.IMG_Mxit),
      h.BuddyType.SERVICE2: Type(h.BuddyType.SERVICE2,_("MXit Service"),c.SERVICE,ic.IMG_Mxit),
      h.BuddyType.INVITE: Type(h.BuddyType.INVITE,_("Invitation"),c.INVITE,ic.IMG_Invite),
      h.BuddyType.GALLERY: Type(h.BuddyType.GALLERY,_("MXit File Service"),c.FILESERVICE,ic.IMG_Mxit),
      h.BuddyType.INFO: Type(h.BuddyType.INFO,_("MXit Service"),c.SERVICE,ic.IMG_Mxit),
      h.BuddyType.ROOM: Type(h.BuddyType.ROOM,_("MultiMx"),c.ROOM,ic.IMG_Room),
   };


   # PRESENCES
   presences = {
      h.Presence.OFFLINE: Presence(h.Presence.OFFLINE,_("Offline"),ic.IMG_Offline,ic.IMG_NewOffline,ic.ICON_Offline),
      h.Presence.AVAILABLE: Presence(h.Presence.AVAILABLE,_("Online"),ic.IMG_Online,ic.IMG_NewOnline,ic.ICON_Online),
      h.Presence.CHAT: Presence(h.Presence.CHAT,_("Online"),ic.IMG_Online,None,ic.ICON_Online),
      h.Presence.AWAY: Presence(h.Presence.AWAY,_("Away"),ic.IMG_Away,None,ic.ICON_Away),
      h.Presence.XA: Presence(h.Presence.XA,_("Away"),ic.IMG_Away,None,ic.ICON_Away),
      h.Presence.BUSY: Presence(h.Presence.BUSY,_("Busy"),ic.IMG_Busy,None,ic.ICON_Busy)
   };
   orderedPresences = [presences[h.Presence.AVAILABLE],
                       presences[h.Presence.OFFLINE],
                       presences[h.Presence.AWAY],
                       presences[h.Presence.BUSY]];

   # MOODS
   moods = {
      h.Mood.NONE: Mood(h.Mood.NONE,_("None"),ic.IMG_Blank),
      h.Mood.ANGRY: Mood(h.Mood.ANGRY,_("Angry"),ic.IMG_Angry),
      h.Mood.EXCITED: Mood(h.Mood.EXCITED,_("Excited"),ic.IMG_Excited),
      h.Mood.GRUMPY: Mood(h.Mood.GRUMPY,_("Grumpy"),ic.IMG_Grumpy),
      h.Mood.HAPPY: Mood(h.Mood.HAPPY,_("Happy"),ic.IMG_Happy),
      h.Mood.INLOVE: Mood(h.Mood.INLOVE,_("In Love"),ic.IMG_InLove),
      h.Mood.INVINCIBLE: Mood(h.Mood.INVINCIBLE,_("Invincible"),ic.IMG_Invincible),
      h.Mood.SAD: Mood(h.Mood.SAD,_("Sad"),ic.IMG_Sad),
      h.Mood.HOT: Mood(h.Mood.HOT,_("Hot"),ic.IMG_Hot),
      h.Mood.SICK: Mood(h.Mood.SICK,_("Sick"),ic.IMG_Sick),
      h.Mood.SLEEPY: Mood(h.Mood.SLEEPY,_("Sleepy"),ic.IMG_Sleepy),
   };

   # EMOTICONS
   emotes = [
      Emoticon(":)", ic.EMOTE_Smile, _("Smile")),
      Emoticon(":(", ic.EMOTE_Sad, _("Sad")),
      Emoticon(";)", ic.EMOTE_Wink, _("Wink")),
      Emoticon(":D", ic.EMOTE_Excited, _("Excited")),
      Emoticon(":|", ic.EMOTE_Shocked, _("Shocked")),
      Emoticon(":O", ic.EMOTE_Surprised, _("Surprised")),
      Emoticon(":P", ic.EMOTE_Tongue, _("Tongue")),
      Emoticon(":$", ic.EMOTE_Embarrassed, _("Embarrassed")),
      Emoticon("8-)", ic.EMOTE_Cool, _("Cool")),
      Emoticon("(H)", ic.EMOTE_Heart, _("Heart")),
      Emoticon("(F)", ic.EMOTE_Flower, _("Flower")),
      Emoticon("(m)", ic.EMOTE_Male, _("Male")),
      Emoticon("(f)", ic.EMOTE_Female, _("Female")),
      Emoticon("(*)", ic.EMOTE_Star, _("Star")),
      Emoticon("(c)", ic.EMOTE_Hot, _("Hot")),
      Emoticon("(x)", ic.EMOTE_Kiss, _("Kiss")),
      Emoticon("(i)", ic.EMOTE_Idea, _("Idea")),
      Emoticon(":e", ic.EMOTE_Angry, _("Angry")),
      Emoticon(":x", ic.EMOTE_Censored, _("Censored")),
      Emoticon("(z)", ic.EMOTE_Grumpy, _("Grumpy")),
      Emoticon("(U)", ic.EMOTE_Coffee, _("Coffee")),
      Emoticon("(G)", ic.EMOTE_GreenHappy, _("Mr Green")),
      Emoticon(":o(", ic.EMOTE_Sick, _("Sick")),
      Emoticon(":{", ic.EMOTE_Astonished, _("Astonished")),
      Emoticon(":}", ic.EMOTE_InLove, _("In Love")),
      Emoticon("8o", ic.EMOTE_Roll, _("Rolling Eyes")),
      Emoticon(":'(", ic.EMOTE_Crying, _("Crying")),
      Emoticon(":?", ic.EMOTE_Thinking, _("Thinking")),
      Emoticon(":~", ic.EMOTE_Drooling, _("Drooling")),
      Emoticon(":z", ic.EMOTE_Sleepy, _("Sleepy")),
      Emoticon(":L)", ic.EMOTE_Liar, _("Liar")),
      Emoticon("8|", ic.EMOTE_Nerdy, _("Nerdy")),
      Emoticon("P-)", ic.EMOTE_Pirate, _("Pirate")),
   ];